import React, { Component } from 'react'
import style from "./redetail.module.css"
import axios from "axios"
class index extends Component {
    state={
        show:false,
        ida:0,
        data:[]
    }
    componentDidMount(){
        console.log(this.props.location.state,'1111')
        this.bbb()
        
    }
    bbb(){
        // console.log(this.props);
        let {id} =this.props.location.state
      
        const headerJSON = {
            "Content-Type": "application/json;charset=UTF-8"
        };
        axios({
            url: "/loupan/recommend/selectRecommend/",
            method: 'post',
            data:{
                id:id
            },
            headers: headerJSON,
        }).then(res => {
            this.state.data= res.data[0]
         console.log(this.state.data,"res")
         this.setState({
            
        })
     
        })
       
    
    }
    
    render() {
        return (
            <div >
                <div className={style.main}>
                <div className={style.top}>
                <p><span onClick={()=>{
                    this.props.history.push("./center/recommond")
                }}>&lt;</span>资讯-问答详情</p>
                </div>
               
                
             
             <div className={style.content}>
           
                          <span><img src={this.state.data.rimg}/></span>
                          <i>{this.state.data.rname}</i>
                      {   
                      !this.state.show&&<button onClick={()=>{
                        this.state.show=!this.state.show
                        this.state.ida+=1
                          this.setState({})
                      }}>+关注</button>
                          }
                     {
                         this.state.show&& <button onClick={()=>{
                            this.state.show=!this.state.show
                            this.state.ida-=1
                            this.setState({})
                            
                        
                        }}>已关注</button>
                     }
                      </div >        
       {/* <div className={style.con}>
                 {this.state.data.rdescribe}
             </div>) */}
             <div className={style.con} dangerouslySetInnerHTML={{ __html:this.state.data.rdescribe}} />
            </div>
            </div>
        )
    }
}
export default index
